package work.MrSun.xyq.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import work.MrSun.xyq.mapper.XyqMessageMapper;
import work.MrSun.xyq.model.XyqMessage;
import work.MrSun.xyq.util.SameService;

import java.util.List;

/**
 * @Author MrSun
 * @Date 2023/4/9 21:09
 */

/**
 * 详细信息的实现层
 */
@Service
public class XyqMessageDetailService extends SameService<XyqMessage> {

    @Autowired
    private XyqMessageMapper xyqMessageMapper;

    //获取丢失信息
    public XyqMessage getLostMessage(){
        return xyqMessageMapper.getLostMessage();
    }
    //获取热点话题
    public XyqMessage getHotTopic(){
        return xyqMessageMapper.getHotTopic();
    }

    public Integer insertMessageDetail(XyqMessage xyqMessage) {
        return xyqMessageMapper.insertMessageDetail(xyqMessage);
    }


    //根据用户id进行查询 详细信息
    public List<XyqMessage> getMessageDetailByUserId(Integer userId){
        return xyqMessageMapper.getMessageDetailByUserId(userId);
    }
    //获取所有的信息
    public List<XyqMessage> getAllMessage(){
        return xyqMessageMapper.getAllMessage();
    }
    /**
     * 根据分类里查询信息进行搜索
     */
    public List<XyqMessage> getMessageByCategoryAndKeyword(Integer id,String keyword){
        return xyqMessageMapper.getMessageByCategoryAndKeyword(id,keyword);
    }
    /**
     * 全局进行搜索
     */
    public List<XyqMessage> getMessageByKeyword(String keyword){
        return xyqMessageMapper.getMessageByKeyword(keyword);
    }

    /**
     * 查询分类的所有信息----获取分类具体信息
     */
   public List<XyqMessage> getMessageByCategoryId(Integer id){
        return xyqMessageMapper.getMessageByCategoryId(id);
    }

    /**
     * 删除对应信息下的所有的评论以及回复
     * @param messageId
     */
    public void deleteCommentAndReply(Integer messageId) {

        xyqMessageMapper.deleteCommentAndReply(messageId);
    }
}
